package ua.yandex.skipasssystem.skipass;


import ua.yandex.skipasssystem.SkiPassSystemInterface;
import ua.yandex.skipasssystem.skipass.enums.NumberOfDays;
import ua.yandex.skipasssystem.skipass.enums.NumberOfLifts;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.EnumMap;

public class SkiPassMaker {

    SkiPassSystemInterface skiPassSystem;

    public SkiPassMaker(SkiPassSystemInterface skiPassSystem) {
        this.skiPassSystem = skiPassSystem;
    }

    public SkiPass makeNumberOfLiftsSkiPass(LocalDate fromDate,
                                            LocalDate toDate,
                                            NumberOfLifts liftsNumber,
                                            EnumMap<DayOfWeek,
                                                    Boolean> daysOfWork) {
        long id = skiPassSystem.getNewSkiPassId();
        SkiPass skiPass = new NumberOfLiftsSkiPass(id,
                fromDate,
                toDate,
                liftsNumber,
                daysOfWork);
        skiPassSystem.addSkiPass(skiPass);
        return skiPass;
    }

    public SkiPass makeNumberOfDaysSkiPass(LocalDate fromDate,
                                           LocalDate toDate,
                                           NumberOfDays daysNumber,
                                           EnumMap<DayOfWeek,
                                                   Boolean> daysOfWork) {
        long id = skiPassSystem.getNewSkiPassId();
        SkiPass skiPass = new NumberOfDaysSkiPass(id,
                fromDate,
                toDate,
                daysNumber,
                daysOfWork);
        skiPassSystem.addSkiPass(skiPass);
        return skiPass;
    }

    public SkiPass makePartOfDayUnlimSkiPass(LocalDate fromDate,
                                             LocalDate toDate,
                                             LocalTime fromTime,
                                             LocalTime toTime,
                                             EnumMap<DayOfWeek,
                                                     Boolean> daysOfWork) {
        long id = skiPassSystem.getNewSkiPassId();
        SkiPass skiPass = new PartOfDayUnlimSkiPass(id,
                fromDate,
                toDate,
                fromTime,
                toTime,
                daysOfWork);
        skiPassSystem.addSkiPass(skiPass);
        return skiPass;
    }

    public SkiPass makeSeasonSkiPass(LocalDate fromDate,
                                     LocalDate toDate) {
        long id = skiPassSystem.getNewSkiPassId();
        SkiPass skiPass = new SeasonSkiPass(id, fromDate, toDate);
        skiPassSystem.addSkiPass(skiPass);
        return skiPass;
    }
}
